/*
 * Copyright Iain Sproat, 2009
 * 
 *
 */
using System;

namespace FreeBase.Domain
{
	/// <summary>
	/// The equivalent of freebase /type/boolean
	/// </summary>
	public class FBBoolean : FBValueType<bool>
	{
		public FBBoolean()
		{
		}
		public FBBoolean( string val )
		{
			this.Value = bool.Parse(val);
		}
		
		public override bool Value { get; set; }
		
		public static implicit operator FBBoolean( bool boolValue )
		{
			FBBoolean b = new FBBoolean();
			b.Value = boolValue;
			return b;
		}
		
		public static implicit operator FBBoolean( string stringValue )
		{
			if( string.IsNullOrEmpty( stringValue ) )
				throw new ArgumentNullException( "stringValue" );
			
			FBBoolean b = new FBBoolean();
			if( stringValue == "null" )
				b.Value = false;
			else
				b.Value = bool.Parse( stringValue );
			return b;
		}
	}
}
